//
//  CategoryTableViewCell.m
//  LNH
//
//  Created by twentylx on 2018/1/15.
//  Copyright © 2018年 twentylx. All rights reserved.
//

#import "CACategoryTableViewCell.h"

@implementation CACategoryTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (instancetype) initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self addSubview:self.bgView];
        [self.bgView addSubview:self.titleLabel];
        [self.bgView addSubview:self.cateImageView];
        [self addSubview:self.bottomView];
        
        [_bgView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.and.right.equalTo(self);
            make.top.equalTo(self);
            make.height.mas_equalTo(140);
        }];
        
        [_titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.bgView).offset(40);
            make.centerY.equalTo(self.bgView);
        }];
        
        [_cateImageView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.bgView).offset(10);
            make.right.equalTo(self.bgView).offset(-40);
            make.width.mas_equalTo(130);
            make.height.mas_equalTo(120);
            
        }];
        
        [_bottomView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.and.right.equalTo(self);
            make.top.equalTo(self.bgView.mas_bottom);
            make.bottom.equalTo(self);
        }];
        
    }
    return self;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    
    // Configure the view for the selected state
}

- (UIView *)bgView {
    if (!_bgView) {
        _bgView = [UIView new];
        _bgView.backgroundColor = RGBCOLOR(228, 228, 228);
    }
    return _bgView;
}

- (UILabel *)titleLabel {
    if (!_titleLabel) {
        _titleLabel = [UILabel new];
        _titleLabel.text = @"";
        _titleLabel.font = [UIFont systemFontOfSize:24 weight:1];
    }
    return _titleLabel;
}

- (UIImageView *) cateImageView {
    if (!_cateImageView) {
        _cateImageView = [UIImageView new];
//        _cateImageView.contentMode = UIViewContentModeCenter;
    }
    return _cateImageView;
}

- (UIView *)bottomView {
    if (!_bottomView) {
        _bottomView = [UIView new];
        _bottomView.backgroundColor = [UIColor whiteColor];
    }
    return _bottomView;
}

@end
